True if key is currently present in target, false otherwise. The way to know, BEFORE calling map_get, whether the value it would give back is real or just the missing-key default.
map_has(target, key) -> bool| Name | Type |
|---|---|
target | map |
key | mapkey |
bool
true if key is currently present in target, false otherwise.
This is the way to know, BEFORE calling map_get, whether the value it would give back is real or just the missing-key default.
/// @type {map<string,int>}
var scores = {};
map_set(scores, "alice", 10);
var has_alice = map_has(scores, "alice"); // true
var has_bob = map_has(scores, "bob"); // false



Just the hash map's contains() - O(1) average.